﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

namespace Utility.Inspector
{
	public abstract class BaseScope
	{
		public struct ScopeRef : IDisposable
		{
			BaseScope scope;
			public ScopeRef (BaseScope scope)
			{
				this.scope = scope;
			}

			void IDisposable.Dispose ()
			{
				scope.End ();
			}
		}

		public ScopeRef Begin ()
		{
			OnBegin ();
			return new ScopeRef (this);
		}

		public void End ()
		{
			OnEnd ();
		}

		protected abstract void OnBegin ();
		protected abstract void OnEnd ();
	}
}
